package com.party.course.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.party.common.annotation.Log;
import com.party.common.core.controller.BaseController;
import com.party.common.core.domain.AjaxResult;
import com.party.common.enums.BusinessType;
import com.party.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.party.course.domain.CoachTime;
import com.party.course.service.ICoachTimeService;
import com.party.common.core.page.TableDataInfo;

/**
 * 教练时间Controller
 *
 * @author ruoyi
 * @date 2025-05-29
 */
@RestController
@RequestMapping("/course/CoachTime" )
public class CoachTimeController extends BaseController {
    @Autowired
    private ICoachTimeService coachTimeService;

/**
 * 查询教练时间列表
 */
//@RequiresPermissions("course:CoachTime:list")
@GetMapping("/list" )
    public TableDataInfo list(CoachTime coachTime) {
        startPage();
        List<CoachTime> list = coachTimeService.findList(coachTime);
        return getDataTable(list);
    }

    /**
     * 导出教练时间列表
     */
    //@RequiresPermissions("course:CoachTime:export")
    @Log(title = "教练时间" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, CoachTime coachTime) {
        List<CoachTime> list = coachTimeService.findList(coachTime);
        ExcelUtil<CoachTime> util = new ExcelUtil<CoachTime>(CoachTime. class);
        util.exportExcel(response, list, "教练时间数据" );
    }

    /**
     * 获取教练时间详细信息
     */
    //@RequiresPermissions("course:CoachTime:query")
    @GetMapping(value = "/view/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) String id) {
        return AjaxResult.success(coachTimeService.view(id));
    }

    /**
     * 新增教练时间
     */
    //@RequiresPermissions("course:CoachTime:add")
    @Log(title = "教练时间" , businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CoachTime coachTime) {
        return toAjax(coachTimeService.add(coachTime));
    }

    /**
     * 修改教练时间
     */
    //@RequiresPermissions("course:CoachTime:edit")
    @Log(title = "教练时间" , businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody CoachTime coachTime) {
        return toAjax(coachTimeService.updateEntity(coachTime));
    }

    /**
     * 删除教练时间
     */
    //@RequiresPermissions("course:CoachTime:remove")
    @Log(title = "教练时间" , businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{id}" )
    public AjaxResult remove(@PathVariable String id) {
        return toAjax(coachTimeService.removeById(id));
    }
}
